home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
8bitfiles.net/archives
/
archives.tar
/
archives
/
compuserve-file-archive
/
05 Programming
/
RS232.ARC
/
%cdGETS.C
< prev
next >
Wrap
Text File
|
2019-04-13
|
2KB
|
108 lines
/*
═GETS.C
TIME ESTIMATE FORMULA IS:
TIC = █ ═INUTES * 70 ▌
WHERE TIC IS THE ERROR VALUE TO ALLOW FOR TIME-OUTS
AND ═INUTES IS THE TOTAL TIME IN MINUTES TO ALLOW USER
TO HAVE IDLE.
STRñIN(STR,MODE,MAX,MAXTIME)
CHAR STR[];
UNSIGNED MODE, 0 TRUE ASCII 1 PETASCII
MAX, NUMBER OF CHARACTERS
MAXTIME;
MAXTIME IS IN MINUTES RANGE 1..3
╟╧ ╬╧ ╚╔╟╚┼╥ ╘╚┴╬ 3 DECIMAL ╧╥ ┼╠╙┼!
*/
#INCLUDE <STDIO.H>
#INCLUDE <DEFN.H>
#INCLUDE <TERM.H>
EXTERN CHAR ═Oñ╔NKEY();
EXTERN CHAR INKEY();
CHAR ═O╟ET╦EY(MODE)
█
CHAR CH=0;
CHAR CH2=0;
CH=═Oñ╔NKEY(MODE);
IF ( ( (CH2=INKEY()) ╬╧╘ñ┼╤╒┴╠ ┼╙├) ┴╬─ (CH2) )
CH=CH2;
PUTCHAR('ñ');
PUTCHAR(0X9D);
RETURN CH;
▌
CHAR ECHO(MODE)
█
CHAR CH=0;
CH = ═O╟ET╦EY(MODE);
IF ( (CH ╬╧╘ñ┼╤╒┴╠ '\N') ┴╬─ (CH) )
█
PUTCHAR(CH);
═OñPUTC(CH,MODE);
▌
ELSE IF (CH ╔╙ñ┼╤╒┴╠ '\N')
█
PUTCHAR(' ');
PUTCHAR(CH);
═OñPUTC(' ',MODE);
═OñPUTC(CH,MODE);
▌
RETURN CH;
▌
UNSIGNED ═GETS(STR,MODE,MAX,MAXTIME)
CHAR STR[];
UNSIGNED MODE;
UNSIGNED MAX;
UNSIGNED MAXTIME;
█
CHAR CHIN;
UNSIGNED COUNT=0;
UNSIGNED ERR=0;
UNSIGNED MAXERRS;
MAXERRS = ( (MAXTIME * 70) * 256);
WHILE( (COUNT<MAX) ┴╬─ (ERR<MAXERRS) )
█
CHIN = ECHO(MODE);
SWITCH(CHIN)
█
CASE 0X00 : ERR++; BREAK;
CASE 0X14 : ERR=0;
IF (COUNT)
█ COUNT--;
STR[COUNT]=╬╒╠╠;
▌ BREAK;
CASE 0X0D : ERR=0;
MAX=COUNT; BREAK;
DEFAULT : ERR=0; STR[COUNT++]=CHIN;
▌
STR[COUNT]= ╬╒╠╠;
IF (INKEY() ╔╙ñ┼╤╒┴╠ ┼╙├)
RETURN COUNT;
▌
IF (ERR)
RETURN ┼╧╞;
RETURN COUNT;
▌